extends Area2D

enum{ADD_LIFE,PAUSE_EMEMYS,PROTECT_HOME,BOOM_ENEMYS,WEAPON_UP,INVINCIBLE}

var _prop_type setget set_prop_type

var invincible_time=10

func set_prop_type(prop_type):
	_prop_type=prop_type
	$Sprite.frame=_prop_type

func _ready():
	set_prop_type(randi()%6)
	self.position=Vector2(rand_range(48.0,432.0),rand_range(32.0,448.0))
	$ChangeTimer.start()

func _on_Prop_body_entered(body):
	if _prop_type==ADD_LIFE:
		Global.set_life_num(Global.get_life_num()+1)
	elif _prop_type==PAUSE_EMEMYS:
		get_tree().current_scene.get_node("EnemysManager").set_pause(20)
	elif _prop_type==PROTECT_HOME:
		get_tree().current_scene.get_node("Home").set_golden()
	elif _prop_type==BOOM_ENEMYS:       
		get_tree().current_scene.get_node("EnemysManager").boom_enemys()
	elif _prop_type==WEAPON_UP:
		body.set_player_level_num(body.get_player_level_num()+1)
	elif _prop_type==INVINCIBLE:
		body.set_invincible(invincible_time)
	queue_free()
	pass # Replace with function body.


func _on_ChangeTimer_timeout():
	set_prop_type((_prop_type+1)%6)
	pass # Replace with function body.
